package com.service.impl;

import javax.annotation.PostConstruct;
import com.dto.User;
import com.github.pagehelper.PageHelper;
import com.mapper.UserMapper;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author HuangSuip
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public String getName() {
        User u = new User();
        return userMapper.selectByPrimaryKey(1).getName();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insert(User user) {
        return userMapper.insert(user);
    }

    @Override
    public String getUserNameById(Integer id) {
        PageHelper.startPage(1,10);
        User s =  userMapper.selectByPrimaryKey(id);
        return s.getName();
    }


    @PostConstruct
    public void construct() {
        LOGGER.info(String.valueOf(userMapper));
    }


}
